package com.hong.springcloud.service;

import com.hong.springcloud.entity.Product;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * Created by John on 2018/11/27.
 */
@Component // 不要忘记添加
public class ProductClientServiceFallbackFactory implements FallbackFactory<ProductClientService> {

    @Override
    public ProductClientService create(Throwable throwable) {
        return new ProductClientService() {
            @Override
            public Product get(Long id) {
                return new Product().setId(id).setDescription("该ID：" + id + "没有没有对应的信息,Consumer客户端提供的降级信息,此刻服务Provider已经关闭");
            }

            @Override
            public Map<String, Object> list() {
                return null;
            }

            @Override
            public int add(Product product) {
                return 0;
            }
        };
    }
}
